from flask import Blueprint, request, render_template
from models import Lock, File
from exts import db

bp = Blueprint("lock", __name__, url_prefix="/lock")


@bp.route('/unlock', methods=['GET', 'POST'])
def upload():
    password = request.values.get('password')
    if password == db.session.query(Lock).first().password:
        content = {
            "files": db.session.query(File).all()
        }
        return render_template("download.html", **content)
    else:
        return "密码错误"
